#pragma once

#include "pch.h"
#include "prerequisites.h"
#include "texture.h"
#include "vector4.h"
#include "matrix4x4.h"

class c_gpu_program 
{
public:
    c_gpu_program(ID3DXConstantTable *constant_table)
        : m_constant_table(constant_table) {}
    virtual ~c_gpu_program();
    
    void set_vector4(const std::string& param_name, const c_vector4& val);
    void set_matrix4x4(const std::string& param_name, const c_matrix4x4& val);

protected:
    ID3DXConstantTable *m_constant_table; 
};

//////////////////////////////////////////////////////////////////////////

class c_gpu_vertex_program : public c_gpu_program
{
    friend gpu_vertex_program_ptr create_vs_from_file(const std::string& file_name); 
public:
    IDirect3DVertexShader9* get_d3d9_vs(); 
    ~c_gpu_vertex_program(); 

private:
    explicit c_gpu_vertex_program(ID3DXBuffer *buf, ID3DXConstantTable *constant_table);

private: 
    IDirect3DVertexShader9 *m_d3d9_vs; 
};

/////////////////////////////////////////////////////////////////////////

class c_gpu_pixel_program : public c_gpu_program
{
    friend gpu_pixel_program_ptr create_ps_from_file(const std::string& file_name); 
public:
    ~c_gpu_pixel_program(); 
    IDirect3DPixelShader9* get_d3d9_ps(); 

private: 
    explicit c_gpu_pixel_program(ID3DXBuffer *buf, ID3DXConstantTable *constant_table);

private:
    IDirect3DPixelShader9 *m_d3d9_ps; 
};

bool compile_shader_from_file(const std::string& file_name, const std::string& profile, ID3DXBuffer **pp_buf, ID3DXConstantTable **pp_constant_table);